var curPageName = "admin-role";
changeCurrent();

var projectName = $("#projectName").val();

function updaterole(){
	var role_id = trim($("#role_id").val());
	var role_name = trim($("#role_name").val());
	var role_description = trim($("#role_description").val());
	
	var mids = "";
	$("td input[type='checkbox']").each(function(){
		if($(this).attr("checked")){
			if(mids != ""){
				mids += "|";
			}
			mids += $(this).siblings("input[type='hidden']").val();
		}
	})
	
	
	if(role_name == ""){
		myAlert("角色名称不能为空！");
	} else if(role_description == ""){
		myAlert("角色描述不能为空！");
	} else if(mids == ""){
		myAlert("请先选择角色模块！");
	} else {
		$.ajax({
			url: projectName+"/admin-role/ajaxupdate?var="+(new Date()).getTime(),
			type: "POST",
			dataType: "text",
			data: {"roleId":role_id, "roleName":role_name, "roleDescription":role_description, "mids":mids},
			success: function(str){
				if(str=="ok"){
					location.href=projectName+"/admin-role/index";
				} else {
					myAlert(str);
				}
			}
		})
	}
	
}